<?php

	namespace Aspic;
	
	use Aspic as A;
	
	/**
	 * An extension of the PHP DateTime class to provide Storable value for 
	 * STRow class.
	 * @see Model\STRow
	 */
	 class DateTime extends \DateTime implements \StorableObjectInterface {

		public function toStorableString() {
			$timeFormat = $this->format('His');
			 
			 // If no time data
			 if ($timeFormat == '000000') {
				 return $this->format('Y-m-d');
			 }
			 else {
				 return $this->format('Y-m-d H:i:s');
			 }
		}

		public static function fromStorableString($storableString) {
			$obj = new DateTime($storableString);
			
			return $obj;
		}

	 }

?>
